package com.pshcp.doctor.tool;

import com.framework.base.BaseDTO;
import com.framework.exception.BizException;
import com.framework.thread.ReqComTool;
import com.framework.tool.CommonTool;
import com.framework.util.SystemUtil;
import com.pshcp.doctor.ao.sendmessage.DoctorSendMessagePageAO;
import com.pshcp.doctor.ao.sendmessage.SaveDoctorSendMessageAO;
import com.pshcp.domain.dto.DoctorSendMessageContentDTO;
import com.pshcp.domain.model.DoctorSendMessageContent;
import com.pshcp.domain.model.DoctorSendMessagePatient;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * @Description: TODO
 * @Author: xiaoche
 * @Date: 2022/11/4 17:27
 */
public class DoctorSendMessageTool {

    public static DoctorSendMessageContentDTO buildGetDoctorSendMessagePage(DoctorSendMessagePageAO doctorSendMessagePageAO) {
        BaseDTO baseDTO = CommonTool.buildBaseDTO(doctorSendMessagePageAO.getPageNum(), doctorSendMessagePageAO.getPageSize());
        DoctorSendMessageContentDTO doctorSendMessageContentDTO = new DoctorSendMessageContentDTO();
        doctorSendMessageContentDTO.setPageNum(baseDTO.getPageNum());
        doctorSendMessageContentDTO.setPageSize(baseDTO.getPageSize());
        doctorSendMessageContentDTO.setSearch(doctorSendMessagePageAO.getSearch());
        doctorSendMessageContentDTO.setDoctorId(ReqComTool.getUserId());
        return doctorSendMessageContentDTO;
    }

    public static void checkSaveDoctorSendMessage(SaveDoctorSendMessageAO saveDoctorSendMessageAO) throws BizException {
        CommonTool.checkString(saveDoctorSendMessageAO.getContent(),"10130001");
        CommonTool.checkObj(saveDoctorSendMessageAO.getPatientIds(),"10130002");
    }

    public static DoctorSendMessageContent buildSaveDoctorSendMessageContent(SaveDoctorSendMessageAO saveDoctorSendMessageAO){
        DoctorSendMessageContent doctorSendMessageContent=new DoctorSendMessageContent();
        doctorSendMessageContent.setDoctorId(ReqComTool.getUserId());
        doctorSendMessageContent.setContent(saveDoctorSendMessageAO.getContent());
        return doctorSendMessageContent;
    }
    public static List<DoctorSendMessagePatient> buildSaveDoctorSendMessagePatientList(Long doctorSendMessageContentId,Long[] patientIds){
        List<DoctorSendMessagePatient>list=new ArrayList<>();
        DoctorSendMessagePatient doctorSendMessagePatient=null;
        for (Long patientId : patientIds) {
            doctorSendMessagePatient=new DoctorSendMessagePatient();
            doctorSendMessagePatient.setId(SystemUtil.getId());
            doctorSendMessagePatient.setDoctorSendMessageContentId(doctorSendMessageContentId);
            doctorSendMessagePatient.setDoctorId(ReqComTool.getUserId());
            doctorSendMessagePatient.setPatientId(patientId);
            doctorSendMessagePatient.setStatus(0);
            list.add(doctorSendMessagePatient);
        }
        return list;
    }
}
